import type { FormRules } from 'element-plus'

// 表单字段配置
export interface FormField {
  label: string
  prop: string
  component: string
  type?: string // 输入类型，如'text', 'textarea', 'password'等
  rules?: FormRules
  componentProps?: Record<string, any>
  colSpan?: number
  fullWidth?: boolean
  visible?: boolean
  disabled?: boolean
  required?: boolean
  placeholder?: string
  options?: Array<{ label: string; value: any; disabled?: boolean }>

  // Select组件特有属性
  multiple?: boolean
  filterable?: boolean
  allowCreate?: boolean
  defaultFirstOption?: boolean
  remote?: boolean
  remoteMethod?: (query: string) => void
  loading?: boolean
  clearable?: boolean
}

// 表单状态
export interface FormState {
  data: Record<string, any>
  initialData: Record<string, any>
  isDirty: boolean
  errors: Record<string, string>
  loading: boolean
  submitting: boolean
}

// 对话框状态
export interface DialogState {
  visible: boolean
  title: string
  width: string | number
  fullscreen: boolean
  top: string | number
  modal: boolean
  appendToBody: boolean
  lockScroll: boolean
  closeOnClickModal: boolean
  closeOnPressEscape: boolean
  showClose: boolean
  destroyOnClose: boolean
  center: boolean
  draggable: boolean
}

// 表单对话框配置选项
export interface FormDialogOptions {
  title?: string
  width?: string | number
  fullscreen?: boolean
  top?: string | number
  modal?: boolean
  appendToBody?: boolean
  lockScroll?: boolean
  closeOnClickModal?: boolean
  closeOnPressEscape?: boolean
  showClose?: boolean
  destroyOnClose?: boolean
  center?: boolean
  draggable?: boolean
  validateOnSubmit?: boolean
  resetOnClose?: boolean
  formData?: Record<string, any>
  fields: FormField[]
}

// 表单对话框事件
export interface FormDialogEvents {
  'update:modelValue': (value: boolean) => void
  'form-change': (form: Record<string, any>) => void
  'validation-error': (fields: Record<string, any>) => void
  confirm: (form: Record<string, any>) => void
  cancel: () => void
}
